﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace Lekce06
{
    public class Program
    {
        private static OutputPort R0 = new OutputPort(Pins.GPIO_PIN_D12,false);
        private static OutputPort R1 = new OutputPort(Pins.GPIO_PIN_D11, false);

        private static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);


        private static InputPort B = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);
        
        public static void Main()
        {
            var b0 = new Button(Pins.GPIO_PIN_D10);
            b0.ButtonClick += Relay0_Clip;

            var b1 = new Button(Pins.GPIO_PIN_D9);
            b1.ButtonClick += Relay1_Clip;

            while (true)
            {
                led.Write(B.Read());
                b0.ReadState();
                b1.ReadState();
            }
        }


        private static void Relay0_Clip()
        {
            R0.Write(!R0.Read()); 
        }

        private static void Relay1_Clip()
        {
            R1.Write(!R1.Read());
        }
    }
}
